from db import db

class Stream(db.Model): 
    __tablename__ = 'stream'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(255), nullable=False)
    title = db.Column(db.String(255), nullable=False)
    cover = db.Column(db.String(255), nullable=False)
    room_id = db.Column(db.Integer, nullable=False)
    view = db.Column(db.Integer, nullable=False)
    status = db.Column(db.Integer, nullable=False)

    def __init__(self,username,title,cover,roomId):
        self.username = username
        self.title = title
        self.cover = cover
        self.room_id = roomId
        self.view = 0
        self.status = 0
    
    def to_dict(self):
        return {
            'id': self.id,
            'username': self.username,
            'title': self.title,
            'cover': self.cover,
            'roomId': self.room_id,
            'view': self.view,
            'status': self.status
        }